package com.zhang.utils;

import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class MyMailUtil {
    public static String sendEmail(String accept){
        String code = null;
        try {
            MailAccount account = new MailAccount();
            account.setHost("smtp.qq.com");
            account.setPort(587);
            account.setAuth(true);
            account.setFrom("1071511540@qq.com");
            account.setUser("1071511540@qq.com");
            account.setPass("boiguinwlqdjbbha");
            List<String> acceptor = new ArrayList<>();
            acceptor.add(accept);
            code = String.valueOf((new Random().nextInt(899999) + 100000));
            MailUtil.send(account,acceptor,"你想象不到的快乐",code,false);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return code;
    }
}
